#include "drv_dma.h"
#include "stdio.h"
#include "string.h"
void drv_dma2_init(uint32_t *src,uint32_t *drc,uint32_t size)
{
	DMA_InitTypeDef  DMA_InitStruct;
	RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_DMA2, ENABLE);
	DMA_InitStruct.DMA_BufferSize = size;
	DMA_InitStruct.DMA_Channel = DMA_Channel_0;
	DMA_InitStruct.DMA_DIR = DMA_DIR_MemoryToMemory;
	DMA_InitStruct.DMA_FIFOMode = DMA_FIFOMode_Disable;
	DMA_InitStruct.DMA_Memory0BaseAddr = (uint32_t)drc;
	DMA_InitStruct.DMA_MemoryBurst = DMA_MemoryBurst_Single;
	DMA_InitStruct.DMA_MemoryDataSize = DMA_MemoryDataSize_Word;
	DMA_InitStruct.DMA_MemoryInc = DMA_MemoryInc_Enable;
	DMA_InitStruct.DMA_Mode = DMA_Mode_Normal;
	
	DMA_InitStruct.DMA_PeripheralBaseAddr = (uint32_t)src;
	DMA_InitStruct.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
	DMA_InitStruct.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;
	DMA_InitStruct.DMA_PeripheralInc = DMA_PeripheralInc_Enable;
	DMA_InitStruct.DMA_Priority = DMA_Priority_High;
	DMA_Init(DMA2_Stream0, & DMA_InitStruct);

	DMA_Cmd(DMA2_Stream0, ENABLE);
}

void drv_dma2_compare(uint32_t d[],uint32_t s[],uint32_t size)
{
	uint8_t i=0,j=0;
	for(i=0,j=0;i<size &&j<size;i++,j++)
	{
		if(d[i] !=s[j])
		{
			printf("d[%d]=%d  s[%d]=%d",i,d[i],j,s[j]);
			printf("data is err\r\n");
			return;
		}
	}
	printf("data is cor\r\n");
}
